package net.lanelife.casino.caipiao.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import net.lanelife.casino.caipiao.entity.support.UserRelationEntity;
import net.lanelife.casino.common.entity.annotation.Checked;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * @author User
 * 配额记录
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "TB_QUOTA_RECORD")
public class QuotaRecord extends UserRelationEntity<Integer> {

	private static final long serialVersionUID = -9170500666166933778L;

	@Checked
	@Column(name = "CHILD_NAME", length = 16, nullable = false)
	private String childName = "";
	
	@Checked
	@Column(name = "BEGIN_REBATE_POINT", nullable = false)
	private Double beginRebatePoint;

	@Checked
	@Column(name = "END_REBATE_POINT", nullable = false)
	private Double endRebatePoint;
	
	@Checked
	@Column(name = "QUOTA", nullable = false)
	private Long quota;
	
	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "DIRECTION", nullable = false)
	private Direction direction;

	@Checked
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "TYPE", nullable = false)
	private Type type;
	
	public static enum Direction {
		/**
		 * 收入
		 */
		IN,
		/**
		 * 支出
		 */
		OUT
	}
	
	public static enum Type {
		/**
		 * 系统发放      -- 管理后台进行发放
		 */
		IN_SYSTEM_GIVE,
		/**
		 * 上级发放      -- 前台上级发放给下级（记录下级）
		 */
		IN_PARENT_GIVE,
		/**
		 * 配额回收      -- 因下级降点而返还配额给上级（记录上级）
		 */
		IN_PARENT_RECY,
		/**
		 * 配额返还      -- 因下级返点调整返还配额给上级
		 */
		IN_QUOTA,
		
		/**
		 * 系统回收      -- 管理后台进行回收，或由于返点级别调整而回收
		 */
		OUT_SYSTEM_RECY,
		/**
		 * 配额发放      -- 前台上级发放给下级（记录上级）
		 */
		OUT_PARENT_GIVE,
		/**
		 * 上级回收      -- 因下级降点而返还配额给上级（记录下级）
		 */
		OUT_PARENT_RECY,
		/**
		 * 配额扣除      -- 因开户或返点调整扣除上级配额
		 */
		OUT_QUOTA
	}
	
	public QuotaRecord() {}
	
	public QuotaRecord(User user) {
		super(user);
	}
	
	public String getChildName() {
		return childName;
	}

	public void setChildName(String childName) {
		this.childName = childName;
	}

	public Double getBeginRebatePoint() {
		return beginRebatePoint;
	}

	public void setBeginRebatePoint(Double beginRebatePoint) {
		this.beginRebatePoint = beginRebatePoint;
	}

	public Double getEndRebatePoint() {
		return endRebatePoint;
	}

	public void setEndRebatePoint(Double endRebatePoint) {
		this.endRebatePoint = endRebatePoint;
	}

	public Long getQuota() {
		return quota;
	}

	public void setQuota(Long quota) {
		this.quota = quota;
	}

	public Direction getDirection() {
		return direction;
	}

	public void setDirection(Direction direction) {
		this.direction = direction;
	}

	public Type getType() {
		return type;
	}

	public void setType(Type type) {
		this.type = type;
	}
	
}
